Skip to main content

Single Message APIs

The following APIs can be used to send templates to end users. Please import the collection from the Single Message API Collection.


Prerequisites
  1. WhatsApp Business Account: Share the following details with the Msgkart team so they can send messages on your behalf:

    • BusinessId
    • PhoneNumberId
    • Template
  2. Msgkart Account: Once you share the above details, the Msgkart team will create an account for you and provide an API Key.


Request Syntax

POST /api/v1/message/<WHATSAPP BUSINESS ID>/<MESSAGE TYPE>?apikey=<API KEY>

Request Body

{
"message": {
"messageType": "<Message Type>",
"name": "<Template Name>",
"language": "<Language Code>",
"components": []
},
"to": "<Subscriber Id>",
"phoneNumberId": "<Phone Number Id>"
}

Response Body

{
"transactionId": "9bb17cdf-759b-4238-8165-be3191db38dc",
"messageId": "b40b3d68-8514-4792-95f3-a32dbbafb1a6"
}

Properties

PlaceholderDescriptionSample
messageTypeType of the message being sent. Possible value: templatetemplate
nameName of the template created in WhatsApp Business accountpayment_template
languageLanguage code used to create the templateen_US
componentsList of components like header, body, etc.
toEnd user phone number919999999999
phoneNumberIdPhone number ID from WhatsApp Business account

Components

{
"componentType": "<Component Type>",
"index": "0",
"sub_type": "<url>",
"parameters": []
}

Properties

PlaceholderDescriptionSample
componentTypeType of component (body, header, button)body
indexRequired for button components. Possible values: 0, 1, 20
sub_typeRequired for buttons. Defines the button action (url)url
parametersList of parameters that describe the component

Parameters

{
"type": "<Parameter Type>",
"text": "Any text",
"code": "Currency Code",
"amount": "<amount>",
"date": "<Date>",
"payload": "<button Payload>",
"mediaLink": "<Link to the media object>",
"mediaType": "<media type>",
"fileName": "<File name>"
}

Properties

ParameterDescriptionSample
typeParameter type (currency, text, date_time, payload, media.)text
textAny text to set in the templateMsgKart, Pay now
codeCurrency code (used for currency type)INR
amountAmount to be charged (for currency type)1000
dateDate to set in the component (for date_time type)June 6th 2023
payloadThis field is used only when the component type is button. Its returned when the button is clicked
mediaLinkURL of the media object
mediaTypeType of media (image, video, document)image
fileNameName of the document (for media type)document.pdf

Examples

Example 1: Template with Header, Body, and Buttons

curl --location 'https://alb-backend.msgkart.com/api/v1/message/<Business Id>/template?apikey=<API KEY>' \
--header 'Content-Type: application/json' \
--data '{
"message": {
"messageType": "template",
"name": "<Template Name>",
"language": "<Language Code>",
"components": [
{
"componentType": "header",
"parameters": [
{
"type": "media",
"mediaLink": "https://www.msgkart.com/assets/images/pages/logo/color-light.png",
"mediaType": "image"
}
]
},
{
"componentType": "button",
"index": "0",
"sub_type": "url",
"parameters": [
{ "type": "text", "text": "nXdPLQ4cgZ" },
{ "type": "payload", "text": "UUID" }
]
},
{
"componentType": "body",
"parameters": [
{ "type": "date_time", "date": "June 6th 2023" },
{ "type": "currency", "code": "INR", "amount": 1000 },
{ "type": "text", "text": "MsgKart" }
]
}
]
},
"to": "<Subscriber Id>",
"phoneNumberId": "<Phone number Id>"
}'

Alt text for the image

Example 2: Template with a PDF Document

curl --location 'https://alb-backend.msgkart.com/api/v1/message/<Business ID>/template?apikey=<API KEY>' \
--header 'Content-Type: application/json' \
--data '{
"message": {
"messageType": "template",
"name": "test_doc_camp",
"language": "en_US",
"components": [
{
"componentType": "header",
"parameters": [
{
"type": "media",
"mediaLink": "https://example.com/file.pdf",
"mediaType": "document",
"fileName": "Test.pdf"
}
]
}
]
},
"to": "919739316704",
"phoneNumberId": "126875363728090"
}'